<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
  <title>碳排放核算模型</title>
  <script>
    function calculateBuildingEmissions() {
      var naturalGasConsumption = parseFloat(document.getElementById("building-natural-gas-consumption").value);
      var liquefiedPetroleumGasConsumption = parseFloat(document.getElementById("building-liquefied-petroleum-gas-consumption").value);
      var dieselConsumption = parseFloat(document.getElementById("building-diesel-consumption").value);
      var electricityConsumption = parseFloat(document.getElementById("building-electricity-consumption").value);
      var heatConsumption = parseFloat(document.getElementById("building-heat-consumption").value);
      var naturalGasEmissionFactor = parseFloat(document.getElementById("building-natural-gas-emission-factor").value);
      var liquefiedPetroleumGasEmissionFactor = parseFloat(document.getElementById("building-liquefied-petroleum-gas-emission-factor").value);
      var dieselEmissionFactor = parseFloat(document.getElementById("building-diesel-emission-factor").value);
      var electricityEmissionFactor = parseFloat(document.getElementById("building-electricity-emission-factor").value);
      var heatEmissionFactor = parseFloat(document.getElementById("building-heat-emission-factor").value);

      var emissions = (naturalGasConsumption * naturalGasEmissionFactor +
        liquefiedPetroleumGasConsumption * liquefiedPetroleumGasEmissionFactor +
        dieselConsumption * dieselEmissionFactor +
        electricityConsumption * electricityEmissionFactor +
        heatConsumption * heatEmissionFactor) * 0.001;

      document.getElementById("building-emissions").innerHTML = "建筑碳排放量为：" + emissions.toFixed(2) + " tCO2";
    }

    function calculateTransportEmissions() {
      var vehicleTrips = parseFloat(document.getElementById("transport-vehicle-trips").value);
      var averageDistance = parseFloat(document.getElementById("transport-average-distance").value);
      var energyConsumption = parseFloat(document.getElementById("transport-energy-consumption").value);
      var emissionFactor = parseFloat(document.getElementById("transport-emission-factor").value);
      var roadTrafficFlow = parseFloat(document.getElementById("transport-road-traffic-flow").value);
      var roadLength = parseFloat(document.getElementById("transport-road-length").value);

      var parkingEmissions = (vehicleTrips * averageDistance * energyConsumption * emissionFactor) * 0.00001;
      var roadFlowEmissions = (roadTrafficFlow * roadLength * energyConsumption * emissionFactor) * 0.00001;

      document.getElementById("transport-emissions-parking").innerHTML = "基于停车车次的交通CO2排放量为：" + parkingEmissions.toFixed(2) + " tCO2";
      document.getElementById("transport-emissions-road-flow").innerHTML = "基于道路车流量的交通CO2排放量为：" + roadFlowEmissions.toFixed(2) + " tCO2";
    }

    function calculateMunicipalEmissions() {
      var waterConsumption = parseFloat(document.getElementById("municipal-water-consumption").value);
      var electricityConsumption = parseFloat(document.getElementById("municipal-electricity-consumption").value);
      var sewageCh4EmissionFactor = parseFloat(document.getElementById("municipal-sewage-ch4-emission-factor").value);
      var sewageN2OEmissionFactor = parseFloat(document.getElementById("municipal-sewage-n2o-emission-factor").value);
      var wasteCo2EmissionFactor = parseFloat(document.getElementById("municipal-waste-co2-emission-factor").value);
      var population = parseFloat(document.getElementById("municipal-population").value);
      var waste = parseFloat(document.getElementById("municipal-waste").value);

      var waterEmissions = (waterConsumption * 0.065);
      var electricityEmissions = (electricityConsumption * 0.4512);
      var sewageCh4Emissions = (waste * sewageCh4EmissionFactor);
      var sewageN2OEmissions = (sewageN2OEmissionFactor * population);
      var wasteCo2Emissions = (waste * wasteCo2EmissionFactor);
      var municipalEmissions = waterEmissions + electricityEmissions + sewageCh4Emissions + sewageN2OEmissions + wasteCo2Emissions;

      document.getElementById("municipal-water-emissions").innerHTML = "区域用水CO2排放量为：" + waterEmissions.toFixed(2) + " tCO2";
      document.getElementById("municipal-electricity-emissions").innerHTML = "市政路灯CO2排放量为：" + electricityEmissions.toFixed(2) + " tCO2";
      document.getElementById("municipal-sewage-ch4-emissions").innerHTML = "生活污水CH4排放量为：" + sewageCh4Emissions.toFixed(2) + " tCH4";
      document.getElementById("municipal-sewage-n2o-emissions").innerHTML = "生活污水N2O排放量为：" + sewageN2OEmissions.toFixed(2) + " tCO2";
      document.getElementById("municipal-waste-co2-emissions").innerHTML = "生活垃圾CO2排放量为：" + wasteCo2Emissions.toFixed(2) + " tCO2";
      document.getElementById("municipal-emissions").innerHTML = "市政碳排放量为：" + municipalEmissions.toFixed(2) + " tCO2";
    }

    function calculateCarbonSink() {
      var greenArea = parseFloat(document.getElementById("carbon-sink-green-area").value);
      var carbonSinkFactor = parseFloat(document.getElementById("carbon-sink-factor").value);

      var carbonSink = greenArea * carbonSinkFactor;

      document.getElementById("carbon-sink-absorption").innerHTML = "碳汇吸收量为：" + carbonSink.toFixed(2) + " tCO2";
    }
  </script>
</head>
<body>
  <h1>建筑核算模型</h1>
  <form>
    <label for="building-natural-gas-consumption">天然气消耗量（m3）:</label>
    <input type="text" id="building-natural-gas-consumption" placeholder="天然气消耗量"><br>

    <label for="building-liquefied-petroleum-gas-consumption">液化石油气消耗量（kg）:</label>
    <input type="text" id="building-liquefied-petroleum-gas-consumption" placeholder="液化石油气消耗量"><br>

    <label for="building-diesel-consumption">柴油消耗量（kg）:</label>
    <input type="text" id="building-diesel-consumption" placeholder="柴油消耗量"><br>

    <label for="building-electricity-consumption">电力消耗量（kWh）:</label>
    <input type="text" id="building-electricity-consumption" placeholder="电力消耗量"><br>

    <label for="building-heat-consumption">热力消耗量（GJ）:</label>
    <input type="text" id="building-heat-consumption" placeholder="热力消耗量"><br>

    <label for="building-natural-gas-emission-factor">天然气排放因子（kgCO2/m3）:</label>
    <input type="text" id="building-natural-gas-emission-factor" value="2.165" placeholder="天然气排放因子" ><br>

    <label for="building-liquefied-petroleum-gas-emission-factor">液化石油气排放因子（kgCO2/kg）:</label>
    <input type="text" id="building-liquefied-petroleum-gas-emission-factor" value="2.924" placeholder="液化石油气排放因子" ><br>

    <label for="building-diesel-emission-factor">柴油排放因子（kgCO2/kg）:</label>
    <input type="text" id="building-diesel-emission-factor" value="3.1451" placeholder="柴油排放因子" ><br>

    <label for="building-electricity-emission-factor">电力排放因子（kgCO2/kWh）:</label>
    <input type="text" id="building-electricity-emission-factor" value="0.4512" placeholder="电力排放因子" ><br>

    <label for="building-heat-emission-factor">热力排放因子（kgCO2/GJ）:</label>
    <input type="text" id="building-heat-emission-factor" value="110" placeholder="热力排放因子" ><br>

    <button type="button" onclick="calculateBuildingEmissions()">计算</button>
  </form>
  <p id="building-emissions"></p>

  <h1>交通核算模型</h1>
  <form>
    <label for="transport-vehicle-trips">车辆停车车次（次）:</label>
    <input type="text" id="transport-vehicle-trips" placeholder="车辆停车车次"><br>

    <label for="transport-average-distance">出行平均公里数（km/次）:</label>
    <input type="text" id="transport-average-distance" placeholder="出行平均公里数"><br>

    <label for="transport-energy-consumption">单位百公里能源消耗量:</label>
    <input type="text" id="transport-energy-consumption" placeholder="单位百公里能源消耗量"><br>

    <label for="transport-emission-factor">CO2排放因子:</label>
    <input type="text" id="transport-emission-factor" value="2.165" placeholder="CO2排放因子" ><br>

    <label for="transport-road-traffic-flow">道路车流量（PCU/年）:</label>
    <input type="text" id="transport-road-traffic-flow" placeholder="道路车流量"><br>

    <label for="transport-road-length">道路长度（km）:</label>
    <input type="text" id="transport-road-length" placeholder="道路长度"><br>

    <button type="button" onclick="calculateTransportEmissions()">计算</button>
  </form>
  <p id="transport-emissions-parking"></p>
  <p id="transport-emissions-road-flow"></p>

  <h1>市政核算模型</h1>
  <form>
    <label for="municipal-water-consumption">区域用水量（t）:</label>
    <input type="text" id="municipal-water-consumption" placeholder="区域用水量"><br>

    <label for="municipal-electricity-consumption">市政路灯总耗电量（kWh）:</label>
    <input type="text" id="municipal-electricity-consumption" placeholder="市政路灯总耗电量"><br>

    <label for="municipal-sewage-ch4-emission-factor">生活污水CH4排放因子（kgCH4/t）:</label>
    <input type="text" id="municipal-sewage-ch4-emission-factor" value="0.0089" placeholder="生活污水CH4排放因子" ><br>

    <label for="municipal-sewage-n2o-emission-factor">生活污水N2O排放因子（kgCO2/人·年）:</label>
    <input type="text" id="municipal-sewage-n2o-emission-factor" value="0.05754" placeholder="生活污水N2O排放因子" ><br>

    <label for="municipal-waste-co2-emission-factor">生活垃圾CO2排放因子（kgCO2/t）:</label>
    <input type="text" id="municipal-waste-co2-emission-factor" value="2717" placeholder="生活垃圾CO2排放因子" ><br>

    <label for="municipal-population">区域总人口（人）:</label>
    <input type="text" id="municipal-population" placeholder="区域总人口"><br>

    <label for="municipal-waste">生活垃圾总量（t）:</label>
    <input type="text" id="municipal-waste" placeholder="生活垃圾总量"><br>

    <button type="button" onclick="calculateMunicipalEmissions()">计算</button>
  </form>
  <p id="municipal-water-emissions"></p>
  <p id="municipal-electricity-emissions"></p>
  <p id="municipal-sewage-ch4-emissions"></p>
  <p id="municipal-sewage-n2o-emissions"></p>
  <p id="municipal-waste-co2-emissions"></p>
  <p id="municipal-emissions"></p>

  <h1>碳汇核算模型</h1>
  <form>
    <label for="carbon-sink-green-area">绿化面积（公顷）:</label>
    <input type="text" id="carbon-sink-green-area" placeholder="绿化面积"><br>

    <label for="carbon-sink-factor">碳汇系数（tCO2/公顷）:</label>
    <input type="text" id="carbon-sink-factor" value="3.67" placeholder="碳汇系数" ><br>

    <button type="button" onclick="calculateCarbonSink()">计算</button>
  </form>
  <p id="carbon-sink-absorption"></p>
</body>
</html>
